package com.youlai.boot.util.lwb;

import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.pinyin.PinyinUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;

import java.util.*;

public class TestExcel1 {
    public static void main(String[] args) {
//        try {
            String filePath = "E://项目数据导入模版_1.xls";
            ExcelReader excelReader = ExcelUtil.getReader(filePath);
            String[] sheet2Columns = new String[]{"3", "6", "7", "10", "14", "16", "18", "19", "37", "38", "46", "47", "52", "122", "123"};
            List<String> indexList = Arrays.asList(sheet2Columns);

//            List<String> objects = new ArrayList<>();
//
//                      <el-tab-pane label="目标实现情况" name="目标实现情况"></el-tab-pane>
//                    <el-tab-pane label="地质油气藏" name="地质油气藏"></el-tab-pane>
//                    <el-tab-pane label="钻井" name="钻井"></el-tab-pane>
//                    <el-tab-pane label="完井" name="完井"></el-tab-pane>
//                    <el-tab-pane label="采油" name="采油"></el-tab-pane>
//                    <el-tab-pane label="工程" name="工程"></el-tab-pane>
//                    <el-tab-pane label="生产运行" name="生产运行"></el-tab-pane>
//                    <el-tab-pane label="项目投资" name="项目投资"></el-tab-pane>
//                    <el-tab-pane label="成本指标" name="成本指标"></el-tab-pane>
//                    <el-tab-pane label="产品价格" name="产品价格"></el-tab-pane>
//                    <el-tab-pane label="效益指标" name="效益指标"></el-tab-pane>
            //读取sheet2的数据
            ExcelReader setSheet2 = excelReader.setSheet(1);
            List<List<Object>> sheet2Data = setSheet2.read(2);
            for (List<Object> sheet2Datum : sheet2Data) {

                Object index = sheet2Datum.get(0);
                Integer i = Integer.valueOf(index.toString());
                String title = "";
                if (i < 18) {
                    title = "目标实现情况";
                } else if (i < 50) {
                    title = "地质油气藏";
                } else if (i < 74) {
                    title = "钻井";
                } else if (i < 83) {
                    title = "完井";
                } else if (i < 92) {
                    title = "采油";
                } else if (i < 101) {
                    title = "工程";
                } else if (i < 113) {
                    title = "生产运行";
                } else if (i < 122) {
                    title = "项目投资";
                } else if (i < 125) {
                    title = "成本指标";
                } else if (i < 127) {
                    title = "产品价格";
                } else {
                    title = "效益指标";
                }


                Object name1 = sheet2Datum.get(1);
                Object name = sheet2Datum.get(3);
                Object unit = sheet2Datum.get(2);
                if (StrUtil.isBlank(unit.toString())){
                    unit = "null";
                }
                String pinyin = PinyinUtil.getFirstLetter(name.toString(), "");
                pinyin = pinyin.toLowerCase();
                String filed = pinyin + index;
                String filed1 = pinyin + index + "jb";
                if (indexList.contains(index.toString())) {
                    String sqlInt = "<tr v-show=\"activeTab === '%s' || activeTab === '全部'\">\n" +
                            "                <td>%s</td>\n" +
                            "                <td>%s</td>\n" +
                            "                <td>%s</td>\n" +
                            "                <td>\n" +
                            "                  <el-input-number\n" +
                            "                    v-model=\"formData.%s\"\n" +
                            "                    :controls=\"false\"\n" +
                            "                    :precision=\"2\"\n" +
                            "                    maxlength=\"10\"\n" +
                            "                    style=\"width: 100%%\"\n" +
                            "                  />\n" +
                            "                </td>\n" +
                            "                <td>\n" +
                            "                  <el-input-number\n" +
                            "                    v-model=\"formData.%s\"\n" +
                            "                    :controls=\"false\"\n" +
                            "                    :precision=\"2\"\n" +
                            "                    maxlength=\"10\"\n" +
                            "                    style=\"width: 100%%\"\n" +
                            "                  />\n" +
                            "                </td>\n" +
                            "              </tr>";

                    String format = String.format(sqlInt, title, index, name1, unit, filed, filed1);
                    System.out.println("<!-- 第" + index + "行 -->");
                    System.out.println(format);
                } else {
                    String sql = "<tr v-show=\"activeTab === '%s' || activeTab === '全部'\">\n" +
                            "                <td>%s</td>\n" +
                            "                <td>%s</td>\n" +
                            "                <td>%s</td>\n" +
                            "                <td>\n" +
                            "                  <el-input v-model=\"formData.%s\" maxlength=\"32\" clearable />\n" +
                            "                </td>\n" +
                            "                <td>\n" +
                            "                  <el-input v-model=\"formData.%s\" maxlength=\"32\" clearable />\n" +
                            "                </td>\n" +
                            "              </tr>";
                    String format = String.format(sql, title, index, name1, unit, filed, filed1);
                    System.out.println("<!-- 第" + index + "行 -->");
                    System.out.println(format);

                }
            }

//            System.out.println(sheet2Data);
//
//        } catch (Exception e) {
//            System.err.println("处理Excel文件出错: " + e.getMessage());
//        }
    }
}
